<html>
<script src="../resources/js-test.js"></script>
<script>
function mouseDown() {
    document.getElementById("mousedown_link").style.color = "red";
}
</script>
<a id="normal_link_id" href="http://www.chromium.org">Visit Chromium</a>
<a id="mousedown_link_id" onmousedown="mouseDown()">Click the text!</a>
<button id="button_id" type="button">Button</button>
<details id="details_id">
  <summary id="summary_id">Copyright 2015.</summary>
  <p>The Chromium Authors. All rights reserved.</p>
</details>
<input id="input_datalist_id" list="fruits">
<datalist id="fruits">
  <option value="Apple">
  <option value="Banana">
</datalist>
<input id="input_button_id" type="button" value="Click input button">
<input id="input_checkbox_id" type="checkbox" value="CheckBox"> I have a checkbox
<input id="input_radio_id" type="radio" value="Radio"> Radio
<input type="radio" value="Button"> Button
<menu>
  <input id="menu_button_id" type="button" role="button" value="Click menuitem">
  <input id="menu_checkbox_id" type="checkbox" name="vehicle" value="menuItemCheckbox"> I have a menuItem
  <input id="menu_radio_id" type="radio" name="gender" value="Menu"> Menu
  <input type="radio" name="gender" value="ItemRadio"> ItemRadio
</menu>
Birthday: <input id="input_date_id" type="date" name="bday">
Birthday(date and time): <input id="input_datetime_id" type="datetime" name="bdaytime">
Birthday(datetime-local): <input id="input_datetime-local_id" type="datetime-local" name="bdaytime">
Birthday (month and year): <input id="input_month_id" type="month" name="bdaymonth">
Select a week: <input id="input_week_id" type="week" name="week_year">
Select a file: <input id="input_file_id" type="file" name="img">
Min-Max: <input id="input_number_id" type="number" min="1" max="5">
<input id="input_range_id" type="range" name="points" min="0" max="10">Color: <input id="input_color_id" type="color" name="color">Select a time: <input id="input_time_id" type="time" name="time">
<input id="input_reset_id" type="reset">
<select id="select_id">
  <option id="select_option_id" value="Pacific">Pacific</option>
  <option value="Atlantic">Atlantic</option>
  <option value="Indian">Indian</option>
  <option value="Southern">Southern</option>
  <option value="Arctic">Arctic</option>
</select>
<select id="select_multiple_id" multiple>
  <option id="select_multiple_option_id" value="Milk">Milk</option>
  <option value="Soda">Soda</option>
  <option value="Coffee">Coffee</option>
  <option value="Water">Water</option>
</select>
<textarea id="textarea_id" rows="2" cols="10">
TextArea
</textarea>
<meter id="meter_id" value="0.6">60%</meter>
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0
  <input type="range" id="a" value="50">100
  +<input type="number" id="b" value="50">
  =<output id="output_id" name="x" for="a b"></output>
</form>
<form>
  <label for="blue">Blue</label>
  <input id="input_radio_id" type="radio" name="color" id="blue" value="blue">
  <label for="red">Red</label>
  <input type="radio" name="color" id="red" value="red">  
</form>
<fieldset>
  <legend id="legend_id">Text Input Controls</legend>
  Text: <input id="input_text_id" type="text" name="texttest"><br>
  Password: <input id="input_password_id" type="password" name="passtest"><br>
</fieldset>
<p id="description"></p>
<div id="console"></div>
<script>
description("This test make sure that focusable elements are mapped implicitly to AX roles.");

if (window.testRunner && window.accessibilityController) {
    testRunner.dumpAsText();

    function hasRole(id, expectedRole) {
        debug(id);
        window.elem = accessibilityController.accessibleElementById(id);
        shouldBe("elem.role", "\"" + expectedRole + "\"");
    }

    function hasSingleSelectRole(select_id, option_id) {
        debug(select_id);
        window.elem = accessibilityController.accessibleElementById(select_id);
        shouldBe("elem.role", "\"AXRole: AXPopUpButton\"");
        
        window.axMenuListPopup = elem.childAtIndex(0);
        shouldBe("axMenuListPopup.role", "\"AXRole: AXMenuListPopup\"");

        debug(option_id);
        window.axMenuListOption = axMenuListPopup.childAtIndex(0);
        shouldBe("axMenuListOption.role", "\"AXRole: AXMenuListOption\"");
    }

    hasRole("normal_link_id", "AXRole: AXLink");
    hasRole("mousedown_link_id", "AXRole: AXLink");

    hasRole("button_id", "AXRole: AXButton");
    hasRole("details_id", "AXRole: AXDetails");
    hasRole("summary_id", "AXRole: AXDisclosureTriangle");

    hasRole("input_datalist_id", "AXRole: AXTextFieldWithComboBox");
    hasRole("input_button_id", "AXRole: AXButton");
    hasRole("input_checkbox_id", "AXRole: AXCheckBox");
    hasRole("input_radio_id", "AXRole: AXRadioButton");

    hasRole("menu_button_id", "AXRole: AXButton");
    hasRole("menu_checkbox_id", "AXRole: AXCheckBox");
    hasRole("menu_radio_id", "AXRole: AXRadioButton");

    hasRole("input_date_id", "AXRole: AXDate");
    hasRole("input_datetime_id", "AXRole: AXTextField");
    hasRole("input_datetime-local_id", "AXRole: AXDateTime");
    hasRole("input_month_id", "AXRole: AXDateTime");
    hasRole("input_week_id", "AXRole: AXDateTime");

    hasRole("input_file_id", "AXRole: AXButton");
    hasRole("input_number_id", "AXRole: AXSpinButton");
    hasRole("input_range_id", "AXRole: AXSlider");
    hasRole("input_color_id", "AXRole: AXColorWell");
    hasRole("input_time_id", "AXRole: AXInputTime");
    hasRole("input_reset_id", "AXRole: AXButton");

    hasSingleSelectRole("select_id", "select_option_id");
    hasRole("select_multiple_id", "AXRole: AXListBox");
    hasRole("select_multiple_option_id", "AXRole: AXListBoxOption");

    hasRole("textarea_id", "AXRole: AXTextField");

    hasRole("meter_id", "AXRole: AXMeter");
    hasRole("output_id", "AXRole: AXStatus");
    hasRole("input_radio_id", "AXRole: AXRadioButton");
    hasRole("legend_id", "AXRole: AXLegend");
    hasRole("input_text_id", "AXRole: AXTextField");
    hasRole("input_password_id", "AXRole: AXTextField");
}
</script>
</html>
